

package TransportesMarroquin;

import com.mysql.jdbc.Connection;

import java.awt.event.ActionEvent; 
import java.awt.event.KeyEvent; 
import javax.swing.JButton; 
import javax.swing.JFrame; 
import javax.swing.JLabel; 
import javax.swing.JPanel; 
import javax.swing.JTextField;
import com.mysql.jdbc.ResultSetMetaData;
import com.mysql.jdbc.Statement;
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

public class CamionSelect extends javax.swing.JFrame {

 int num;
 int cve;
  Limitador limani = new Limitador(4);
    Limitador limar = new Limitador(50);
    Limitador limpla = new Limitador(7);
    Limitador limkil = new Limitador(11);
    Limitador limpil = new Limitador(11);
    
    public CamionSelect(int num) {
        initComponents();
         this.num=num;
         cod.setText(""+num);
         cd.setText(""+num);
    cani.setDocument(limani);
    ckil.setDocument(limkil);
    cmar.setDocument(limar);
    cpil.setDocument(limpil);
    cpla.setDocument(limpla);
    acep.setVisible(false);
    bcan.setVisible(false);
         // extrae la informacion de la base de datos 
         
               try {

                // coneccion a la base de datos
        MysqlDataSource datasource= new MysqlDataSource();
        datasource.setUser("root");
        datasource.setPassword("");
        datasource.setDatabaseName("practicasp8");
        datasource.setServerName("localhost");

          Connection conexion = (Connection) datasource.getConnection();


        Statement s = (Statement) conexion.createStatement();

 // query database
 ResultSet resultSet = s.executeQuery( "SELECT * FROM camion where idcamion="+num);
        ResultSetMetaData metaData = (ResultSetMetaData) resultSet.getMetaData();
         int numerodecolumnas = metaData.getColumnCount();

       while (resultSet.next()){

        for(int i=1;i<=numerodecolumnas;i++){
             switch(i){
                 // creo este switch par delimitar el nombre de los label ya establecidos :D
                 case 1:
                     cd.setText(""+resultSet.getObject(i));
                   break;
                 case 2:
                     cpil.setText(""+resultSet.getObject(i));
                   break;
                case 3:
                     cpla.setText(""+resultSet.getObject(i));
                   break;
                 case 4:
                     cani.setText(""+resultSet.getObject(i));
                   break;
                 case 5:
                     cmar.setText(""+resultSet.getObject(i));
                   break;
                 case 6:
                     ckil.setText(""+resultSet.getObject(i));
                 default:
                     ;
                   break;

             }

         } // fin del for
       } // fin del while

        } catch (SQLException ex) {
            Logger.getLogger(ClienteSelect.class.getName()).log(Level.SEVERE, null, ex);
   
        }
    }

    private CamionSelect() {
       
    }

   
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        cpla = new javax.swing.JTextField();
        ckil = new javax.swing.JTextField();
        breg = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        cpil = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        cd = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        bgas = new javax.swing.JButton();
        Llantas = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        cani = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        cmar = new javax.swing.JTextField();
        cvia = new javax.swing.JButton();
        bconf = new javax.swing.JButton();
        acep = new javax.swing.JButton();
        bcan = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        cod = new javax.swing.JLabel();
        n = new javax.swing.JLabel();
        lnum2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel1.setText("C o d i g o ");

        cpla.setEnabled(false);

        ckil.setEnabled(false);
        ckil.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                ckilKeyTyped(evt);
            }
        });

        breg.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/regresar.png"))); // NOI18N
        breg.setText("Regresa");
        breg.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bregActionPerformed(evt);
            }
        });

        jLabel3.setText("Placa");

        jLabel4.setText("Kilometraje");

        cpil.setEnabled(false);
        cpil.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                cpilKeyTyped(evt);
            }
        });

        jLabel2.setText("Codigo Piloto");

        cd.setEnabled(false);
        cd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cdActionPerformed(evt);
            }
        });
        cd.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                cdKeyTyped(evt);
            }
        });

        jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Cabezal.gif"))); // NOI18N

        bgas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/gastos.png"))); // NOI18N
        bgas.setText("Gastos");
        bgas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bgasActionPerformed(evt);
            }
        });

        Llantas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/illanta.png"))); // NOI18N
        Llantas.setText("Llantas");
        Llantas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LlantasActionPerformed(evt);
            }
        });

        jLabel6.setText("Año ");

        cani.setEnabled(false);
        cani.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                caniKeyTyped(evt);
            }
        });

        jLabel7.setText("Marca");

        cmar.setEnabled(false);
        cmar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                cmarKeyTyped(evt);
            }
        });

        cvia.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/iviaje.png"))); // NOI18N
        cvia.setText("Viajes ");
        cvia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cviaActionPerformed(evt);
            }
        });

        bconf.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/config.png"))); // NOI18N
        bconf.setText("Configurar");
        bconf.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bconfActionPerformed(evt);
            }
        });

        acep.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/aceptar.png"))); // NOI18N
        acep.setText("Aceptar");
        acep.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                acepActionPerformed(evt);
            }
        });

        bcan.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/cancelar.png"))); // NOI18N
        bcan.setText("Cancelar");
        bcan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bcanActionPerformed(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(143, 0, 0));

        cod.setFont(new java.awt.Font("Tahoma", 1, 18));
        cod.setForeground(new java.awt.Color(255, 255, 255));
        cod.setText("####");

        n.setFont(new java.awt.Font("Tahoma", 1, 18));
        n.setForeground(new java.awt.Color(255, 255, 255));
        n.setText("No.");

        lnum2.setFont(new java.awt.Font("Tahoma", 1, 18));
        lnum2.setForeground(new java.awt.Color(255, 255, 255));
        lnum2.setText("Camion");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lnum2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 131, Short.MAX_VALUE)
                .addComponent(n)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cod, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lnum2)
                    .addComponent(cod, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(n))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(18, 18, 18)
                        .addComponent(cd, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(18, 18, 18)
                        .addComponent(cpil, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(55, 55, 55)
                        .addComponent(cpla, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addGap(27, 27, 27)
                        .addComponent(ckil, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addGap(58, 58, 58)
                        .addComponent(cani, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addGap(51, 51, 51)
                        .addComponent(cmar, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(140, 140, 140)
                        .addComponent(Llantas, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addGap(13, 13, 13)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(bgas, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cvia, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(bconf, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(breg)
                            .addComponent(acep, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(21, 21, 21)
                        .addComponent(bcan, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(17, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {bconf, breg});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel1))
                    .addComponent(cd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(29, 29, 29)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel2))
                    .addComponent(cpil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(cpla, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(9, 9, 9)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel4))
                    .addComponent(ckil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel6))
                    .addComponent(cani, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel7))
                    .addComponent(cmar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(13, 13, 13)
                .addComponent(Llantas)
                .addGap(5, 5, 5)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(bgas)
                        .addGap(5, 5, 5)
                        .addComponent(cvia)
                        .addGap(5, 5, 5)
                        .addComponent(bconf)))
                .addGap(15, 15, 15)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(breg, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(acep)
                    .addComponent(bcan))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {bconf, breg});

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void bregActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bregActionPerformed
      dispose();
        Camion va;
       
            va = new Camion();
            va.setVisible(true);
            va.setBounds(114, 107, Toolkit.getDefaultToolkit().getScreenSize().width-114, Toolkit.getDefaultToolkit().getScreenSize().height-107);   
       
        
}//GEN-LAST:event_bregActionPerformed

    private void bgasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bgasActionPerformed
      dispose();
   
  int kil = Integer.parseInt(ckil.getText());
  
        Gasto vap = new Gasto("select * from gasto where tipovehiculo like 'Camion' AND idvehiculo ="+num,num,"Camion",kil);
        vap.setVisible(true);
    
        vap.setBounds(114, 107, Toolkit.getDefaultToolkit().getScreenSize().width-114, Toolkit.getDefaultToolkit().getScreenSize().height-107);
    
    }//GEN-LAST:event_bgasActionPerformed

    private void LlantasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LlantasActionPerformed
        
          
      cve=num;
            dispose();
              Llantas vap = new Llantas("select * from llanta where tipo_vehiculo like 'Camion' AND codigo_vehiculo ="+num+" AND cementerio like 'no'","Camion No.",num);
              vap.setVisible(true);
              
              vap.setBounds(114, 107, Toolkit.getDefaultToolkit().getScreenSize().width-114, Toolkit.getDefaultToolkit().getScreenSize().height-107);

        
    }//GEN-LAST:event_LlantasActionPerformed

    private void cviaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cviaActionPerformed
        dispose();
        
        
         Viaje vap = new Viaje("select * from viaje where tipo_vehiculo like 'Camion' AND codigo_vehiculo ="+num,"Camion No.",num);
         vap.setVisible(true);
        
         vap.setBounds(114, 107, Toolkit.getDefaultToolkit().getScreenSize().width-114, Toolkit.getDefaultToolkit().getScreenSize().height-107);
     
}//GEN-LAST:event_cviaActionPerformed

    private void bconfActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bconfActionPerformed
        // obtener el dato de la llave primaria
     //Habilito o deshabilitar
     Llantas.setVisible(false);
     acep.setVisible(true);
     bcan.setVisible(true);
     bconf.setVisible(false);
     breg.setVisible(false);
     bgas.setVisible(false);
     cvia.setVisible(false);

   //Habilito los campos de texto
    cd.setEnabled(true);
    ckil.setEnabled(true);
    cmar.setEnabled(true);
    cpil.setEnabled(true);
    cpla.setEnabled(true);
    cani.setEnabled(true);

}//GEN-LAST:event_bconfActionPerformed

    private void acepActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_acepActionPerformed
        //  opcion
        //UPDATE


        try {
            // coneccion
            //CONFIGURAR
            MysqlDataSource dataSource = new MysqlDataSource();
            dataSource.setUser("root");
            dataSource.setPassword("");
            dataSource.setDatabaseName("practicasp8");
            dataSource.setServerName("localhost");
            Connection conexion = (Connection) dataSource.getConnection();
            Statement instruccion = null;
            instruccion=(Statement) conexion.createStatement();
            // cambio los valores
            instruccion.executeUpdate("update camion set idcamion='"+cd.getText()+"' where idcamion="+num);
            instruccion.executeUpdate("update camion set idpiloto='"+cpil.getText()+"' where idcamion="+num);
            instruccion.executeUpdate("update camion set placa='"+cpla.getText()+"' where idcamion="+num);
            instruccion.executeUpdate("update camion set kilometraje='"+ckil.getText()+"' where idcamion="+num);
            instruccion.executeUpdate("update camion set anio='"+cani.getText()+"' where idcamion="+num);
            instruccion.executeUpdate("update camion set marca='"+cmar.getText()+"' where idcamion="+num);

            JOptionPane.showMessageDialog(rootPane, "Dato cambiado exitosamente" );

            acep.setVisible(false);
            bcan.setVisible(false);
            bconf.setVisible(true);
            breg.setVisible(true);
            Llantas.setVisible(true);
            bconf.setVisible(true);
            breg.setVisible(true);
            bgas.setVisible(true);
            cvia.setVisible(true);
            
          // cajas de texto desabhilitadas   
           cd.setEnabled(false);
           ckil.setEnabled(false);
           cmar.setEnabled(false);
           cpil.setEnabled(false);
           cpla.setEnabled(false);
           cani.setEnabled(false);
        
          

        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(rootPane, "Se ha producido un error al tratar de cambiar el dato. " );
        }

    }//GEN-LAST:event_acepActionPerformed

    private void bcanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bcanActionPerformed
            acep.setVisible(false);
            bcan.setVisible(false);
            bconf.setVisible(true);
            breg.setVisible(true);
            Llantas.setVisible(true);
            bconf.setVisible(true);
            breg.setVisible(true);
            bgas.setVisible(true);
            cvia.setVisible(true);
    }//GEN-LAST:event_bcanActionPerformed

    private void cdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cdActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cdActionPerformed

    private void cdKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cdKeyTyped
              char c = evt.getKeyChar();
       if(!(Character.isDigit(c))|| c== evt.VK_BACK_SPACE || c==evt.VK_DELETE){
           getToolkit().beep();
           evt.consume();
    }//GEN-LAST:event_cdKeyTyped
    }
              private void cpilKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cpilKeyTyped
                         char c = evt.getKeyChar();
       if(!(Character.isDigit(c))|| c== evt.VK_BACK_SPACE || c==evt.VK_DELETE){
           getToolkit().beep();
           evt.consume();

              }//GEN-LAST:event_cpilKeyTyped
    }
                         private void ckilKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_ckilKeyTyped
                                     char c = evt.getKeyChar();
       if(!(Character.isDigit(c))|| c== evt.VK_BACK_SPACE || c==evt.VK_DELETE){
           getToolkit().beep();
           evt.consume();

                         }//GEN-LAST:event_ckilKeyTyped
    }
                                     private void caniKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_caniKeyTyped
                        char c = evt.getKeyChar();
       if(!(Character.isDigit(c))|| c== evt.VK_BACK_SPACE || c==evt.VK_DELETE){
           getToolkit().beep();
           evt.consume();
                                         }
                                     }//GEN-LAST:event_caniKeyTyped

                        private void cmarKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cmarKeyTyped
             char c = evt.getKeyChar();
      if (!(Character.isLetter(c) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE) || ((c== KeyEvent.VK_SPACE)))) {
            getToolkit().beep();
            evt.consume();
}
                        }//GEN-LAST:event_cmarKeyTyped
    

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new CamionSelect().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Llantas;
    private javax.swing.JButton acep;
    private javax.swing.JButton bcan;
    private javax.swing.JButton bconf;
    private javax.swing.JButton bgas;
    private javax.swing.JButton breg;
    private javax.swing.JTextField cani;
    private javax.swing.JTextField cd;
    private javax.swing.JTextField ckil;
    private javax.swing.JTextField cmar;
    private javax.swing.JLabel cod;
    private javax.swing.JTextField cpil;
    private javax.swing.JTextField cpla;
    private javax.swing.JButton cvia;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel lnum2;
    private javax.swing.JLabel n;
    // End of variables declaration//GEN-END:variables

}
